From 5f2de95e00dd56a81a4ed5b026b8bd2e160ac6e7 Mon Sep 17 00:00:00 2001 From: robertlipe Date: Thu, 8 Aug 2013 01:00:10 +0000 Subject: [PATCH] Fix mem clobber in tmpro. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4520 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/tmpro.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gpsbabel/tmpro.cc b/gpsbabel/tmpro.cc index 0cc89866e..1f0089519 100644 --- a/gpsbabel/tmpro.cc +++ b/gpsbabel/tmpro.cc @@ -212,12 +212,11 @@ tmpro_waypt_pr(const waypoint * wpt) /* Number of characters */ /* 25 6 80 8 8 8 8 8 4 4 128 */ - const char *l; + const char *l = NULL; if (wpt->HasUrlLink()) { + // Yes, it's lame to allocate/copy here. UrlLink link = wpt->GetUrlLink(); - l = link.url_.toUtf8().data(); - } else { - l = ""; + l = xstrdup(link.url_.toUtf8().data()); } gbfprintf(file_out, "new\t%.6s\t%.80s\t%08.6f\t%08.6f\t\t\t%.2f\t%d\t%d\t%.128s\n", shortname, @@ -237,6 +236,9 @@ tmpro_waypt_pr(const waypoint * wpt) if (shortname) { xfree(shortname); } + if (l) { + xfree(l); + } } static void -- 2.30.2